<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 100%;
            border: 1px solid red;
            border-spacing: 0;
            border-collapse: collapse;
        }

        td {
            height: 100px;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    行<input type="number">
    列<input type="number">
    <button id="btn">生成</button>
    <table id="tab"></table>
    <script>
        var row = document.getElementsByTagName('input')[0]
        var col = document.getElementsByTagName('input')[1]
        btn.onclick = function () {
            var num1 = row.value
            var num2 = col.value
            var res = ''
            for (var i = 0; i < num1; i++) {
                if (i % 2 === 0) {
                    res += '<tr style="background-color: yellow;">'
                    for (var j = 0; j < num2; j++) {
                        res += '<td>' + '</td>'
                    }
                    res += '</tr>'
                } else {
                    res += '<tr>'
                    for (var j = 0; j < num2; j++) {
                        res += '<td>' + '</td>'
                    }
                    res += '</tr>'
                }

            }
            tab.innerHTML = res
        }
    </script>
</body>

</html>